import 'package:flutter/material.dart';
import 'package:flutter_music/pages/home/models/song.dart';
import 'package:flutter_music/utils/utils.dart';

class HomeSongItem extends StatelessWidget {
  final Song song;
  final VoidCallback? onTap;

  const HomeSongItem({
    super.key,
    required this.song,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.all(8),
        decoration: BoxDecoration(
          color: Theme.of(context).colorScheme.secondary,
          borderRadius: BorderRadius.circular(8),
        ),
        child: Row(
          children: [
            /// 图片
            Utils.loadImage(song.albumArtImageName ?? '', size: const Size(50, 50)),

            /// 名称、作者名
            Expanded(
              child: Padding(
                padding: const EdgeInsets.only(left: 10),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(song.songName ?? ''),
                    Text(
                      song.artistName ?? '',
                      style: TextStyle(
                        fontSize: 12,
                        color: Theme.of(context).colorScheme.primary,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
